package com.mx.kn.cstf2.actions;

import java.sql.SQLException;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.mx.kn.cstf2.dto.CopCompanyDto;
import com.mx.kn.cstf2.dto.UsuarioDto;
import com.mx.kn.cstf2.service.TransitionService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

@Component("copCreationCompany")
@Scope(value = "session")
public class CopCreationCompany extends ActionSupport{
	
	@Autowired
	TransitionService transitionService;
	
	private UsuarioDto usuario = new UsuarioDto();	
	private Integer knKey;
	private String companyName;
	private String comerciaName;
	private String companyAddress;
	private String accountsVisibility;
	private String rfc;
	private String city;
	private String mainContact;
	private String mainContactPhone;
	private String mainContactPosition;
	private String mainContactEmail;
	private String secondContactName;
	private String secondContactPhone;
	private String secondContactPosition;
	private String secondContactEmail;
	private String industry;
	private String subIndustry;
	private boolean activeBillingCustomer;
	private String accountType;
	private String managementSponsor;
	private String investTerm; 
	private boolean top100ByGP;
	private String totalClass;
	private boolean crfa;
	private boolean crfs;
	private boolean crfo;
	private boolean crfx;
	private boolean crfd;
	private boolean crfw;
	private boolean crfg;
	private boolean crfy;
	private boolean crfz;
	
	public Integer getKnKey() {
		return knKey;
	}
	
	public void setKnKey(Integer knKey) {
		this.knKey = knKey;
	}
	
	public String getCompanyName() {
		return companyName;
	}
	
	public void setCompanyName(String companyName) {
		this.companyName = companyName;
	}

	public UsuarioDto getUsuario() {
		return usuario;
	}

	public void setUsuario(UsuarioDto usuario) {
		this.usuario = usuario;
	}

	public String getComerciaName() {
		return comerciaName;
	}

	public void setComerciaName(String comerciaName) {
		this.comerciaName = comerciaName;
	}

	public String getCompanyAddress() {
		return companyAddress;
	}

	public void setCompanyAddress(String companyAddress) {
		this.companyAddress = companyAddress;
	}

	public String getAccountsVisibility() {
		return accountsVisibility;
	}

	public void setAccountsVisibility(String accountsVisibility) {
		this.accountsVisibility = accountsVisibility;
	}

	public String getRfc() {
		return rfc;
	}

	public void setRfc(String rfc) {
		this.rfc = rfc;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getMainContact() {
		return mainContact;
	}

	public void setMainContact(String mainContact) {
		this.mainContact = mainContact;
	}

	public String getMainContactPhone() {
		return mainContactPhone;
	}

	public void setMainContactPhone(String mainContactPhone) {
		this.mainContactPhone = mainContactPhone;
	}

	public String getMainContactPosition() {
		return mainContactPosition;
	}

	public void setMainContactPosition(String mainContactPosition) {
		this.mainContactPosition = mainContactPosition;
	}

	public String getMainContactEmail() {
		return mainContactEmail;
	}

	public void setMainContactEmail(String mainContactEmail) {
		this.mainContactEmail = mainContactEmail;
	}

	public String getSecondContactName() {
		return secondContactName;
	}

	public void setSecondContactName(String secondContactName) {
		this.secondContactName = secondContactName;
	}

	public String getSecondContactPhone() {
		return secondContactPhone;
	}

	public void setSecondContactPhone(String secondContactPhone) {
		this.secondContactPhone = secondContactPhone;
	}

	public String getSecondContactPosition() {
		return secondContactPosition;
	}

	public void setSecondContactPosition(String secondContactPosition) {
		this.secondContactPosition = secondContactPosition;
	}

	public String getSecondContactEmail() {
		return secondContactEmail;
	}

	public void setSecondContactEmail(String secondContactEmail) {
		this.secondContactEmail = secondContactEmail;
	}

	public String getIndustry() {
		return industry;
	}

	public void setIndustry(String industry) {
		this.industry = industry;
	}

	public String getSubIndustry() {
		return subIndustry;
	}

	public void setSubIndustry(String subIndustry) {
		this.subIndustry = subIndustry;
	}

	public boolean isActiveBillingCustomer() {
		return activeBillingCustomer;
	}

	public void setActiveBillingCustomer(boolean activeBillingCustomer) {
		this.activeBillingCustomer = activeBillingCustomer;
	}

	public String getAccountType() {
		return accountType;
	}

	public void setAccountType(String accountType) {
		this.accountType = accountType;
	}

	public String getManagementSponsor() {
		return managementSponsor;
	}

	public void setManagementSponsor(String managementSponsor) {
		this.managementSponsor = managementSponsor;
	}

	public String getInvestTerm() {
		return investTerm;
	}

	public void setInvestTerm(String investTerm) {
		this.investTerm = investTerm;
	}

	public boolean isTop100ByGP() {
		return top100ByGP;
	}

	public void setTop100ByGP(boolean top100ByGP) {
		this.top100ByGP = top100ByGP;
	}

	public String getTotalClass() {
		return totalClass;
	}

	public void setTotalClass(String totalClass) {
		this.totalClass = totalClass;
	}

	public boolean isCrfa() {
		return crfa;
	}

	public void setCrfa(boolean crfa) {
		this.crfa = crfa;
	}

	public boolean isCrfs() {
		return crfs;
	}

	public void setCrfs(boolean crfs) {
		this.crfs = crfs;
	}

	public boolean isCrfo() {
		return crfo;
	}

	public void setCrfo(boolean crfo) {
		this.crfo = crfo;
	}

	public boolean isCrfx() {
		return crfx;
	}

	public void setCrfx(boolean crfx) {
		this.crfx = crfx;
	}

	public boolean isCrfd() {
		return crfd;
	}

	public void setCrfd(boolean crfd) {
		this.crfd = crfd;
	}

	public boolean isCrfw() {
		return crfw;
	}

	public void setCrfw(boolean crfw) {
		this.crfw = crfw;
	}

	public boolean isCrfg() {
		return crfg;
	}

	public void setCrfg(boolean crfg) {
		this.crfg = crfg;
	}

	public boolean isCrfy() {
		return crfy;
	}

	public void setCrfy(boolean crfy) {
		this.crfy = crfy;
	}

	public boolean isCrfz() {
		return crfz;
	}

	public void setCrfz(boolean crfz) {
		this.crfz = crfz;
	}

	public String execute(){
		
		ActionContext contexto = ActionContext.getContext();
   	 	Map<String, Object> sesion = contexto.getSession();
        this.setUsuario((UsuarioDto) sesion.get("usuarioSession"));
        
		return SUCCESS;
	}
	
	public String addCompany() throws SQLException{
		CopCompanyDto compania = new CopCompanyDto();
		compania.setKnKey(getKnKey());
		compania.setCompanyname(getCompanyName());
		compania.setComercianame(getComerciaName());
		compania.setCompanyaddress(getCompanyAddress());
		compania.setAccountsvisibility(getAccountsVisibility());
		compania.setRfc(getRfc());
		compania.setCity(getCity());
		compania.setMaincontact(getMainContact());
		compania.setMaincontactphone(getMainContactPhone());
		compania.setMaincontactposition(getMainContactPosition());
		compania.setMaincontactemail(getMainContactEmail());
		compania.setSecondcontactname(getSecondContactName());
		compania.setSecondcontactphone(getSecondContactPhone());
		compania.setSecondcontactposition(getSecondContactPosition());
		compania.setSecondcontactemail(getSecondContactEmail());
		compania.setIndustry(getIndustry());
		compania.setSubindustry(getSubIndustry());
		compania.setActivebillingcustomer(isActiveBillingCustomer());
		compania.setAccounttype(getAccountType());
		compania.setManagementsponsor(getManagementSponsor());
		compania.setInvestterm(getInvestTerm());
		compania.setTop100bygp(isTop100ByGP());
		compania.setTotalclass(getTotalClass());
		compania.setCrfa(isCrfa());
		compania.setCrfs(isCrfs());
		compania.setCrfo(isCrfo());
		compania.setCrfx(isCrfx());
		compania.setCrfd(isCrfd());
		compania.setCrfw(isCrfw());
		compania.setCrfg(isCrfg());
		compania.setCrfy(isCrfy());
		compania.setCrfz(isCrfz());
		transitionService.newCopTransition(compania,this.getUsuario());
		return SUCCESS;
	}

}
